home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / pascal / scrgo.exe / SCRSTART.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1993-01-31  |  2.8 KB  |  98 lines

  1.  
  2. {$A+}   { Align data }
  3. {$B-}   { Boolean evaluation }
  4. {$E+}   { 80x87 emulator }
  5. {$F-}   { Force FAR calls }
  6. {$G+}   { 80286 code }
  7. {$I-}   { I/O checking }
  8. {$K-}   { Smart Callbacks }
  9. {$N-}   { 80x87 code }
  10. {$O-}   { Overlays allowed }
  11. {$P-}   { Open parameters }
  12. {$T-}   { Typed pointers }
  13. {$V-}   { String VAR checking }
  14. {$W-}   { Windows stack frame for real mode }
  15. {$X+}   { Extended syntax }
  16.  
  17. {$IFDEF DEBUG}
  18.     {$D+}   { Debug information }
  19.     {$L+}   { Local symbols }
  20.     {$Q+}   { Overflow checking }
  21.     {$R+}   { Range checking }
  22.     {$S+}   { Stack checking }
  23.     {$Y+}   { Symbol reference information }
  24. {$ELSE}
  25.     {$D-}   { Debug information }
  26.     {$L-}   { Local symbols }
  27.     {$Q-}   { Overflow checking }
  28.     {$R-}   { Range checking }
  29.     {$S-}   { Stack checking }
  30.     {$Y-}   { Symbol reference information }
  31. {$ENDIF}
  32.  
  33. {$C Moveable Demandload Discardable} { Code Segment attributes }
  34.  
  35. {$M 4096,0}
  36.  
  37. PROGRAM ScrStart;
  38.  
  39. { SCRSTART instantly starts the Windows 3.1 built-in screen saver if the
  40.   user moves the mouse twice within a second into the upper left corner
  41.   of the screen. SCRSTART.EXE requires MAUSHOOK.DLL to work properly.
  42.  
  43.   This is the Pascal version of a C program originaly published in the
  44.   German computer magazine c't (12/92). The C version was written by Peter
  45.   Siering. The problem WITH the C version was that it didn't work properly
  46.   with the Windows debug kernel (the hook function was in the main program,
  47.   not in a DLL). Instead of trying to fix the C program I have re-written
  48.   the whole thing with Borland Pascal 7.0 and separated the program into a
  49.   main program + a DLL. It now works fine with the debug kernel. The EXE +
  50.   DLL created with Pascal also use less memory than the C version!
  51.  
  52.   Uploaded by translator, Olaf Hess, CIS Id 100 031, 35 36.
  53. }
  54.  
  55. USES WinProcs, WinTypes, MHookTpw;
  56.  
  57. VAR
  58.     hTask : THandle;
  59.  
  60. (* ---- *)
  61.  
  62. PROCEDURE WinMain;
  63.  
  64. VAR
  65.     Msg : TMsg;
  66.  
  67. BEGIN
  68.     IF (hPrevInst <> 0) THEN
  69.     BEGIN { Get handle of first instance (notice the Ofs (hTask) !) }
  70.         GetInstanceData (hPrevInst, Ofs (hTask), SizeOf (hTask));
  71.         PostAppMessage (hTask, wm_Quit, 0, 0); { Close it down }
  72.         Halt (0); { Close as well }
  73.     END; { if }
  74.  
  75.     hTask := GetCurrentTask; { Retrieve task handle (save it for later }
  76.  
  77.     IF (NOT InstallMouseHook) THEN { Set the hook }
  78.     BEGIN
  79.         MessageBox (0, 'Failed to install hook', 'Screen Saver Start',
  80.                     mb_IconStop);
  81.         Halt (0);
  82.     END; { if }
  83.  
  84.     WHILE (GetMessage (Msg, 0, 0, 0)) DO
  85.     BEGIN { Business as usual }
  86.         TranslateMessage (Msg);
  87.         DispatchMessage (Msg);
  88.     END; { while }
  89.  
  90.     RemoveMouseHook; { Remove the hook }
  91. END; { WinMain }
  92.  
  93. (* ---- *)
  94.  
  95. BEGIN
  96.     WinMain;
  97. END. { ScrStart }
  98.